import request from '@/utils/request';
import { getRefreshToken } from '@/utils/auth';

/**
 * 获取验证码
 * @param params:{uuid:number}
 * @returns
 */
export const getcheckCodeApi = (params) => {
  return request('/user/checkCode', { params });
};

/**
 * 刷新过期token
 * @returns
 */
export const refreshTokenApi = () => {
  return request({
    url: '/user/refreshToken',
    method: 'post',
    data: { refreshToken: getRefreshToken() },
  });
};

/**
 * 用户登录请求
 * @param params : {username:string,password:string,checkCode:string,uuid:number}
 * @returns
 */
export const userLoginApi = (params) => {
  return request({
    url: '/user/login',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params,
  });
};

/**
 * 
 * @param params :{pageSize:number,currentPage:number,username:string}
 * @returns 
 * username可用于搜索字段
 */
export const userList = (params) => {
  return request({
    url:'/user/list',
    method:'get',
    headers: { 'Content-Type': 'application/json' },
    params,
  })
}
/**
 * 
 * @param params :{pageSize:number,currentPage:number,role_name:String}
 * @returns 
 * role_name 可用于搜索
 */
export const roleList = (params) =>{
  return request({
    url: '/user/role/listRole',
    method:'GET',
    params
  })
}